<style>
#bds-images
{
	width:210px;	
}
.bds-image
{
	margin-bottom:5px;
}
#bds-mota
{
	width:430px;
}
#bds-mota td
{
	border:#000 thin solid;	
}

</style>
<script type="text/javascript" src="<?php echo HTTP_SERVER.DIR_VIEW?>js/jquery.lightbox-0.5.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo HTTP_SERVER.DIR_VIEW?>css/jquery.lightbox-0.5.css" media="screen" />
<script type="text/javascript">
$(function() {
	$('#gallery a').lightBox();
});
</script>
<style type="text/css">
/* jQuery lightBox plugin - Gallery style */
#gallery {
	
	width: 100%;
}
#gallery ul { list-style: none; margin:0; }
#gallery ul li { display: list-item; }
#gallery ul img {
	border: 5px solid #3e3e3e;
	border-width: 5px 5px 5px;
}
#gallery ul a:hover img {
	border: 5px solid #fff;
	border-width: 5px 5px 5px;
	color: #fff;
}
#gallery ul a:hover { color: #fff; }
</style>
<div class="ben-detail">
	<p><?php echo $this->document->getNhom($item['nhucau'])?></p>
    <h4><?php echo $item['tieude'] ?></h4>
    <div class="bds-detail">
    	<div id="bds-images" class="ben-left">
        	<div id="gallery">
                <ul>
                    <li>
                        <a href="<?php echo $item['imagepreview']?>" >
                            <img src="<?php echo $item['imagethumbnail']?>" />
                        </a>
                    </li>
                    <?php 
                        if(count($subimage))
                        {
                            foreach($subimage as $val)
                            {
                            
                    ?>
                    <li>
                        <a href="<?php echo $val['imagepreview']?>" >
                            <img src="<?php echo $val['imagethumbnail']?>"/>
                        </a>
                    </li>
                   <?php
                            }
                        }
                    ?> 
                </ul>
            </div>
        	
        </div>
        <div id="bds-mota" class="ben-right">
        	<table>
            	<tr>
                	<td width="100px">Loại BĐS:</td>
                    <td><?php echo $this->document->getNhom($item['loaibds'])?></td>
                </tr>
                <tr>
                	<td>Diện tích:</td>
                    <td><?php echo $this->string->numberFormate($item['dientich'])?> m&sup2;</td>
                </tr>
                <tr>
                	<td>Diện tích:</td>
                    <td><?php echo $this->document->getNhom($item['huong'])?></td>
                </tr>
                <tr>
                	<td>Địa chỉ:</td>
                    <td><?php echo $item['diachi']?> </td>
                </tr>
               	<tr>
                	<td>Điện thoại:</td>
                    <td><?php echo $this->document->getUser($item['assignto'],'phone')?></td>
                </tr>
                <tr>
                	<td>Ngày:</td>
                    <td><?php echo $this->date->formatMySQLDate($item['createdate'])?></td>
                </tr>
                <tr>
                	<td>Quận huyện:</td>
                    <td><?php echo $this->document->getNhom($item['khuvuc'])?></td>
                </tr>
                <tr>
                	<td>Tỉnh / Thành phố:</td>
                    <td>
                    	<?php if($this->document->getNhom($item['khuvuc'],'nhomcha') != "khuvuc"){ ?>
                        <?php echo  $this->document->getNhom($this->document->getNhom($item['khuvuc'],'nhomcha'))?>
                        <?php } ?>
                    </td>
                </tr>
                <tr>
                	<td>Giá:</td>
                    <td><?php echo $this->string->doc_so1($item['gia'])?></td>
                </tr>
            </table>
            <input type="button" class="ben-button ben-right" value="GỬI LIÊN HỆ" onclick="showForm()">
            <div class="clearer">&nbsp;</div>
            <label>Mô tả</label><br>
            <?php echo html_entity_decode($item['mota'])?>
            
        </div>
        <div class="clearer">&nbsp;</div>
    </div>
</div>
<div id="guilienhe" style="display:none">
	 <div class="ben-error ben-hidden"></div>
	<form method="post" action="" id="contractForm" name="contractForm">

        <input type="hidden" name="bdsid" value="<?php echo $item['bdsid']?>" />
        <table>
        	<tr>
            	<td>Họ tên</td>
                <td><input type="text" name="fullname" id="fullname" class="ben-textbox" size="60" onkeypress='GetKey(event)'/></td>
            </tr>
            <tr>
            	<td>Email</td>
                <td><input type="text" name="email" id="email" class="ben-textbox" size="60" onkeypress='GetKey(event)'/></td>
            </tr>
            <tr>
            	<td>Địa chỉ</td>
                <td><input type="text" name="address" id="address" class="ben-textbox" size="60" onkeypress='GetKey(event)'/></td>
            </tr>
            <tr>
            	<td>Điện thoại</td>
                <td><input type="text" name="phone" id="phone" class="ben-textbox" size="60" onkeypress='GetKey(event)'/></td>
            </tr>
            <tr>
            	<td>Lời nhắn</td>
                <td><textarea name="description" id="description" rows="10" cols="90"></textarea></td>
            </tr>
            <tr>
            	<td></td>
                <td>
                	<input type="button" class="ben-button" value="GỬI LIÊN HỆ" onclick="sendMessage()">
                    <input type="button" class="ben-button" value="ĐÓNG" onclick="closeForm()">
                </td>
            </tr>
        </table>		
    </form>
</div>
<script language="javascript">
function showForm()
{
	$.blockUI(
	{ 
		message: $('#guilienhe'),
		css: { 
			top:  ($(window).height() - 500) /2 + 'px', 
			left: ($(window).width() - 600) /2 + 'px', 
			width: '450px',
			height: '350px',
			padding:'10px'
			}
	});
	$('.blockOverlay').attr('title','Click to close').click(function(){closePopup();});
}

function closeForm()
{
	closePopup();
}

function sendMessage()
{
	$.post(HTTP_SERVER+"?route=module/bds/sendMessage", 
			$("#contractForm").serialize(), 
			function(data)
			{
				if(data!="true")
				{
					$('.ben-error').html(data)
					$('.ben-error').fadeIn("slow")
					//linkto("?<?php echo $refres?>")
				}
				else
				{
					alert("Thông tin của bạn đã gửi đến chúng tôi")
					window.location.reload();
				}
			}
	);
}
</script>